//
//  CompanyOfJobStatusCell.m
//  Btpin
//
//  Created by Vic on 2019/3/26.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "CompanyOfJobStatusCell.h"

@interface CompanyOfJobStatusCell ()
{
    UILabel *jobLbl;
    UILabel *baseInfoLbl;
    UILabel *wageLbl;
    UILabel *dingLbl;
    UILabel *timeLbl;
    UILabel *statusLbl;
}
@end

@implementation CompanyOfJobStatusCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    jobLbl = [UIToolsControl initLabelWithFrame:CGRectMake(LeftSpace, 17*Scale, 300, 26*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_17];
    [self.contentView addSubview:jobLbl];
    
    wageLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(jobLbl), 15*Scale, 185*Scale, 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
    [self.contentView addSubview:wageLbl];
    
    dingLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(wageLbl)+10*Scale, 22*Scale, 15*Scale, 15*Scale) text:@"顶" textColor:COLOR_OF_WHITE font:Font_10];
    dingLbl.backgroundColor = THEMECOLOR_OF_ORANGE;
    dingLbl.layer.cornerRadius = 2;
    dingLbl.layer.masksToBounds = YES;
    dingLbl.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:dingLbl];
    dingLbl.hidden = YES;
    
    baseInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(jobLbl), EndY(jobLbl), WIDTH-100*Scale, 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [self.contentView addSubview:baseInfoLbl];
    
    timeLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(jobLbl), EndY(baseInfoLbl), 200, 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_12];
    [self.contentView addSubview:timeLbl];
    
    statusLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 0, WIDTH-40*Scale, CompanyOfJobStatusCellHeight) text:nil textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_13];
    statusLbl.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:statusLbl];
    
    UIView *lineView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(timeLbl)+10*Scale, WIDTH, 8*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
    [self.contentView addSubview:lineView];
}
- (void)reloadData {
    CGFloat jobWidth = [UIToolsControl textWidth:@"资深程序架构师—App" size:CGSizeMake(MAXFLOAT, 26*Scale) font:Font_17]+10*Scale;
    jobLbl.frame = CGRectMake(LeftSpace, 17*Scale, jobWidth, 26*Scale);
    wageLbl.frame = CGRectMake(EndX(jobLbl), 18*Scale, 150*Scale, 25*Scale);
    
    jobLbl.text = @"资深程序架构师—App";
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@ | %@", @"北京", @"通州", @"3-5年", @"本科"];
    wageLbl.text = @"25k-30k";
    timeLbl.text = @"02月-11日";
    statusLbl.text = @"审核中";
}
- (void)reloadDataModel:(CompanyJobModel *)model {
    CGFloat jobWidth = [UIToolsControl textWidth:model.title size:CGSizeMake(MAXFLOAT, 26*Scale) font:Font_17]+10*Scale;
    CGFloat wageWidth = [UIToolsControl textWidth:model.wage_cn size:CGSizeMake(MAXFLOAT, 25*Scale) font:Font_15]+10*Scale;
    jobLbl.frame = CGRectMake(LeftSpace, 17*Scale, jobWidth, 26*Scale);
    wageLbl.frame = CGRectMake(EndX(jobLbl), 18*Scale, wageWidth, 25*Scale);
    dingLbl.frame = CGRectMake(EndX(wageLbl), 22*Scale, 15*Scale, 15*Scale);
    if ([model.stick isEqualToString:@"1"]) {
        dingLbl.hidden = NO;
    } else {
        dingLbl.hidden = YES;
    }
    
    jobLbl.text = model.title;
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.district_cn, model.experience_cn, model.education_cn];
    wageLbl.text = model.wage_cn;
    timeLbl.text = model.add_timeMMDD;
    
    switch ([model.status integerValue]) {
        case 0: {
            statusLbl.text = model.status_cn;
            statusLbl.textColor = THEMECOLOR_OF_RED;
        } break;
        case 1: {
            statusLbl.text = model.status_cn;
            statusLbl.textColor = THEMECOLOR_OF_GREEN;
        } break;
        case 2: {
            statusLbl.text = model.status_cn;
            statusLbl.textColor = THEMECOLOR_OF_ORANGE;
        } break;
        case 3: {
            statusLbl.text = model.status_cn;
            statusLbl.textColor = THEMECOLOR_OF_RED;
        } break;
        case 4: {
            statusLbl.text = model.status_cn;
            statusLbl.textColor = THEMECOLOR_OF_TEXT_cccccc;
        } break;
        default:
            break;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
